<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp"%>
<title>式神详细信息</title>
</head>
<body>
<%@ include file="/web/front/title/start.jsp"%>
	
<form action="post" enctype="multipart/form-data" onsubmit="return false">
	<div class="xiangqing">
		<div class="neirong w">
			<div name="dename" class="xiaomi6 fl"></div>
			<nav class="fr">
				<li><a href="">概述</a></li>
				<li>|</li>
				<li><a href="">式神背景</a></li>
				<li>|</li>
				<li><a href="">立绘</a></li>
				<li>|</li>
				<li><a href="">技能</a></li>
				<li>|</li>
				<li><a href="">评价</a></li>
				<div class="clear"></div>
			</nav>
			<div class="clear"></div>
		</div>	
	</div>
	<div class="jieshao mt20 w">
	<div class="left fl"><img id="deimg" src="" style="width:560px;height:308px;"></div>
	<div class="right fr">
		<div name="dename" class="h3 ml20 mt20"></div>
		<div name="dedescr" class="jianjie mr40 ml20 mt10"></div>
		<div name="deprice" class="jiage ml20 mt10"></div>
			<div class="xqxq mt20 ml20">
			<div class="top1 mt10"></div>
			<div name="deprice" class="bot mt20 ft20 ftbc"></div>
		</div>
		<div class="xiadan ml20 mt20">
			<input class="jrgwc" type="button" name="scart" value="加入购物车" />
		</div>
	</div>
		<div class="clear"></div>
	</div>
	</form>
	
	<%@ include file="/web/front/title/end.jsp"%>

</body>
	<script type="text/javascript">
	var code = '<%=request.getParameter("code")%>'
	ajax({code:code},'/product/get.do','json',function(data){
		console.log(data)
		$("div[name='dename']").text(data.name);
		$("#deimg").attr("src","/image/"+data.url);
		$("div[name='dedescr']").text(data.descr);
		$("div[name='deprice']").text(data.price+"元");
	})
	
	//加入购物车
	$("input[name='scart']").click(function(){
		ajax({proCode:code},'/scart/add.do','text',function(data){
			if(data==0){
				layer.msg("请先登录！",{
					time:1000
				},
				function(){
					toJsp('/web/front/login.jsp');
				}) 
			}else if(data==1){
				layer.msg("该式神已成功加入购物车！")
			}else{
				layer.msg("加入购物车失败")
			}
		})
	})

// 	得到一级分类
	ajax({parentCode:'type1'},'/cate/getAll.do','json',typeshow)
	function typeshow(data){
		var html1 = '';
		$.each(data,function(i,dom){
			var code = dom.code;
			if(code == 'type1')return;	
			var t1 = "<li><a href='javascript:fenlei(\""+code+"\",1)'>"+dom.name+"</a>"
			html1+=t1+"</li>";
		});
		$("#fenlei1").html(html1);	
	}	
	</script>
</html>